package com.xiaotu.swagger.controller;

import com.xiaotu.swagger.pojo.User;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 张晓
 * @create 2021-09-01 23:10
 */
@RestController
public class HelloController {

    @GetMapping("hello")
    public String hello() {
        return "hello";
    }

    //只要我们接口中，返回值中存在实体类，就会被扫描到Swagger中
    @PostMapping("user")
    public User user() {
        return new User();
    }

    //@ApiOperation 不是放在类上，是放在方法上
    @ApiOperation("Hello 控制类")
    @GetMapping("hello2")
    public String hello2(@ApiParam("用户名") String username) {
        return "hello" + username;
    }

}
